package com.io.MyChar;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/**
 * @author Li
 * @Date 2023/4/23 11:42
 */
public class CharStreamDemo2 {
    /**
     * 将用户输入的用户名和密码，写入文档
     * @param args
     */
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名:");
        String username = scanner.next();
        System.out.println("请输入密码:");
        String password = scanner.next();

        FileWriter fw = new FileWriter("admin.txt");
        fw.write(username);
        fw.write("\r\n");
        fw.write(password);
//        刷新流
        fw.flush();
        fw.close();;
    }
}
